package com.example.javaword;

import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.Pictures;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;

/**
 * @author 41081
 */
public class ImageSimpleDemo1 {
    public static void main(String[] args) throws IOException {
        XWPFTemplate template = XWPFTemplate.compile(Consts.PATH + "template_img.docx").render(
                new HashMap<String, Object>(1) {{
                    put("img", Consts.PATH + "下载.jpg");
                    put("img2", Pictures.ofLocal(Consts.PATH + "下载.jpg").size(120, 120).altMeta("图片不存在啊").create());
                    put("img3", Pictures.ofLocal("logo.png").size(120, 120).altMeta("图片不存在啊").create());
                }});
        template.writeAndClose(Files.newOutputStream(Paths.get(Consts.PATH + "output_img.docx")));
    }
}
